var pullLoading = {
    tpl:"",
    pageNum:1,
    load:function (callback) {
        mui.init({
            pullRefresh : {
                container:"#pullrefresh",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
                up : {
                    style: 'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
                    color: '#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
                    height: '50px',//可选,默认50px.下拉刷新控件的高度,
                    range: '100px', //可选 默认100px,控件可下拉拖拽的范围
                    offset: '0px', //可选 默认0px,下拉刷新控件的起始位置
                    contentnomore:'没有更多数据了',//可选，请求完毕若没有更多数据时显示的提醒内容；
                    auto: false,//可选,默认false.首次加载自动上拉刷新一次
                    callback: function () {
                        pullLoading.pageNum = pullLoading.pageNum+1;
                        url = pullLoading.handleUrl(pullLoading.pageNum);
                        $.ajax({
                            type: 'get',
                            url: url,
                            dataType: 'json',
                        }).done(function (response) {

                            if(response.status){
                                data = response.data.list;
                                var len = data.length;
                                if(len<1){
                                    mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
                                    mui('#pullrefresh').pullRefresh().disablePullupToRefresh();
                                    return true;
                                }
                                callback(data);
                            }
                            mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
                            mui('#pullrefresh').pullRefresh().refresh(true);
                        }).fail(function (XMLHttpRequest) {
                            tooltips('网络异常,请检查连接');

                        }).always(function () {

                        });

                    }
                }
            }
        });
    },
    handleUrl:function () {
        var url = window.location.href;
        if(url.indexOf("page_num=") >= 1){
            var u = url.split("page_num=");
        }else{
            if(url.indexOf("?") >= 1){
                url = url+"&page_num="+this.pageNum;
            }else{
                url = url+"?page_num="+this.pageNum;
            }
        }
        if(u) {
            var e = u[1].split("&");
            var d="";
            if(e.length > 1){
                for(var i=0;i<e.length-1;i++){
                    d += "&"+e[i+1];
                }
            }
            var url = u[0] + "page_num=" + this.pageNum+d;
        }

        return url
    }
};




